package com.bobi.tfca.network.api

import com.bobi.tfca.network.response.ArticleResponse
import com.bobi.tfca.network.response.BaseResponse
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path

interface ArticleAPI {

    /**
     * 发布文章
     */
    @Headers("Content-Type: application/json;charset=utf-8", "Accept: application/json")
    @POST("/article/publishArticle")
    fun publishArticle(@Body article: ArticleResponse) : Call<BaseResponse<Int>>

    /**
     * 获得所有文化展示文章
     */
    @Headers("Accept: application/json")
    @GET("/article/findAllCultures")
    fun findAllCultures() :Call<BaseResponse<ArrayList<ArticleResponse>>>

    /**
     * 查询文章详情
     */
    @Headers("Accept: application/json")
    @GET("/article/getArticleDetails/{articleId}")
    fun getArticleDetails(@Path("articleId") articleId: Int) : Call<BaseResponse<ArticleResponse>>

    @Headers("Accept: application/json")
    @POST("/article/deleteById/{articleId}")
    fun deleteArticle(@Path("articleId") articleId: Int): Call<BaseResponse<String>>

    @Headers("Accept: application/json")
    @POST("/article/likeArticle/{articleId}")
    @FormUrlEncoded
    fun likeArticle(@Field("isLiked") b: Boolean, @Path("articleId") articleId: Int): Call<BaseResponse<String>>
}